<template>
  <el-header class="header">
    <span class="title">首页仪表盘</span>

    <!-- 头像下拉 -->
    <el-dropdown trigger="hover" placement="bottom-end">
      <div class="avatar-box">
        <el-avatar
          size="small"
          src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
        />
        <span class="name">Admin</span>
        <el-icon class="arrow"><CaretBottom /></el-icon>
      </div>

      <template #dropdown>
        <el-dropdown-menu>
          <el-dropdown-item>
            <el-icon><UserFilled /></el-icon>
            个人中心
          </el-dropdown-item>
          <el-dropdown-item>
            <el-icon><Lock /></el-icon>
            锁定屏幕
          </el-dropdown-item>
          <el-dropdown-item divided @click="logout">
            <el-icon><SwitchButton /></el-icon>
            退出登录
          </el-dropdown-item>
        </el-dropdown-menu>
      </template>
    </el-dropdown>
  </el-header>
</template>

<script setup>
import {
  CaretBottom, UserFilled, Lock, SwitchButton
} from '@element-plus/icons-vue'

function logout() {
  // 这里写退出逻辑
  console.log('logout')
}
</script>

<style scoped>
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 24px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.title {
  font-size: 16px;
  font-weight: 600;
}
.avatar-box {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}
.avatar-box:hover {
  background: #f5f5f5;
}
.name {
  margin: 0 6px;
  font-size: 14px;
}
.arrow {
  font-size: 12px;
  color: #666;
}
</style>